約 5,024,914 件
https://w.atwiki.jp/atachi/pages/30.html
コマンドの呼び出し [#o999e49e] コマンドの対象 [#zf5396dd] コマンドの『中身』の実装 [#f2e1a4a6] カスタムコマンドの作成 [#b4d9c788] ICommandを使用したコマンドクラスの実装 [#l2907103] コマンドソースの作成 [#xa070e5b] コマンドを利用することで、コマンドが設定されたコンポーネントの意味とコマンドが実際に行うロジックとの関係が切り離される。 右クリックメニューの「切り取り」「コピー」「貼り付け」はコマンドの代表例である。それぞれの意味は誰しも知っているが、各コマンドがどのような処理を行うかは各アプリケーションが実装しなければならない。 WPFのコマンドもこのような意味であると捉えることができる。 MSDN コマンド実行の概要 WPF コマンド コマンドとは実行されるアクションで、ICommandを継承しアクションを実装します。 コマンドの呼び出しは、コマンドソースから行います。 コマンドソースとはコマンドを呼び出す対象の要素です。ICommandSource を実装したクラスです。 WFPではButtonクラスやMenuItemクラスが実装済みです。 コマンドターゲットとはコマンドを実行する対象の要素です。 コマンドの呼び出し ボタンが押された時にコマンドを呼び出したい場合は、Button.Commandに呼び出したいコマンドを指定します。 Button Command="ApplicationCommands.Open" Image Source="images/FileOpen.png" /Image /Button Button Command="ApplicationCommands.Open" CommandParameter="パラメータ" Image Source="images/FileOpen.png" /Image /Button CommandParameter属性はコマンドのハンドラに渡されるパラメータです。 ICommand.Execute の引数にそのまま渡されます。 コード上からコマンドを呼び出したい場合は、Execute()をコールします。 ApplicationCommands.Paste.Execute(null,textbox1); コマンドの対象 発行されたコマンドを受け取り、コマンドを実行する要素を対象と呼びます。 次の例ではメニューバーから「貼り付け(ApplicationCommands.Paste)」というコマンドを発行した場合に、そのコマンドの実行対象としてmainTextBoxを指定しています。 StackPanel Menu MenuItem Command="ApplicationCommands.Paste" CommandTarget="{Binding ElementName=mainTextBox}" / /Menu TextBox Name="mainTextBox"/ /StackPanel コマンドの『中身』の実装 Windowsアプリケーションでよく使用される「保存」というコマンドは、その意味は誰でも知っているが、何をどのように保存するかはアプリケーションによって異なる。 テキストエディタならばファイルに文字列を保存する事を指しますし、ペインタなどのグラフィックソフトならばビットマップを任意の画像形式で保存します。 このようにコマンドがどのような処理を行うかは、アプリケーション側で実装する必要があります。 あるコマンドを受け取ったときの処理を結びつけることをコマンドバインディングと呼びます。 コマンドバインディングは分離コード、またはXAMLに記述することができます。 コマンドバインディングをコードで実装する場合は、CommandBindingを使用します。 public partical class MainWindow Window { public MainWindow() { InitializeComponent(); // コマンドバインディングの定義 CommandBinding cb = new CommandBinding(); cb.Command = ApplicationCommands.Open; // バインドしたいコマンドの種類 cb.Executed += new ExecutedRoutedEventHandler(onOpenExecuter); this.CommandBinding.Add( cb ); } private void onOpenExecuter(object sender, ExecutedRoutedEventArgs e) { } } また、このコードの等価実装をXAMLで記述することもできます。 Window Window.CommandBindings CommandBinding Command="ApplicationCommands.Open" Execute="onOpenExecuter" / /Window.CommandBindings /Window カスタムコマンドの作成 オリジナルのコマンドを実装したい場合、RoutedCommand または RoutedUICommand の静的なインスタンスを定義します。 static RoutedUICommand StartUp = new RoutedUICommand( "アプリケーションのスタートアップ", "StartUpCommand", typeof(MainWindow)); ICommandを使用したコマンドクラスの実装 namespace my { // コマンドが実行された場合に、任意の処理(アクション)を呼び出す public class RelayCommand ICommand { private readonly Action _execute; private readonly Func bool _canExecute; public RelayCommand(Action execute, Func bool canExecute) { _execute = execute; _canExecute = canExecute; } // ICommand Members public bool CanExecute(object parameter) { // コマンドが実行可能か?? // _canExecuteが設定されている場合は、_canExecuteを使用するが、 // 設定されていない場合は常に「true」とする。 // return _canExecute == null ? true _canExecute(); } // ICommand Members public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } // ICommand Members public void Execute(object parameter) { // コマンド実行時の処理 _execute(); } } } コマンドソースの作成 コマンドソースとはコマンドを発行できるオブジェクト要素です。 C#コードを使えばコマンドは自由に発行できるのですが、XAMLからコマンドを発行したい場合はオブジェクト要素がコマンドソースとなるように実装しなければなりません。 コマンドソースとなるには ICommandSource を継承したオブジェクト要素を作成します。 ButtonクラスはICommandSourceを継承しているので、ICommandSource.CommandによってButtonがクリックされたときに発行するコマンドを指定します。 コマンドソースを実装する場合、ICommandが発行するCanExecuteChangedイベントをハンドリングします。 CanExecuteChangedはICommandが実行可能である場合にtrueを取得できるイベントで、コマンドが発行可能であるかユーザーに知らせることができます。
https://w.atwiki.jp/netnet/pages/30.html
WPF(WindowsPresentationFoundation)関連のTipsはこちらへ Drawing.BitmapからBitmapSourceにする InkCanvasの消しゴムの作り方 RichTextBoxの文字の選択 UserControlをxamlで使いたい WndProcを使用する カスタムコントロールがDesignerでエラーがでる コントロールのサイズを自動調整したい タイトルバーのないウインドウを動かせるようにする
https://w.atwiki.jp/myoss/pages/39.html
MySQLを使ったXAデータソースの設定例(mysql-ds.xml) ?xml version="1.0" encoding="UTF-8"? datasources xa-datasource jndi-name MysqlDS /jndi-name xa-datasource-class com.mysql.jdbc.jdbc2.optional.MysqlXADataSource /xa-datasource-class xa-datasource-property name="URL" jdbc mysql //localhost 3306/test /xa-datasource-property user-name /user-name password /password track-connection-by-tx true /track-connection-by-tx exception-sorter-class-name org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter /exception-sorter-class-name metadata type-mapping mySQL /type-mapping /metadata /xa-datasource /datasources track-connection-by-tx true /track-connection-by-tx を忘れずに。 これをfalseにするとまだMySQLでは実装していないXA派生コマンドをJBossが使ってエラーになります。
https://w.atwiki.jp/wpfapp/
このWikiについて WPF(Windows Presentation Foundation)の情報を扱っています。 比較的新しい技術である故に、使用している人の絶対数が少なく、MFCやWindows FormのようにWWW上に情報が蓄積しているわけでは無いのが現状ですので、ここでできる限りまとめていきたいと思っています。 ある程度の情報量に達するまでは協力してくれる方も出てこないと思うので誰でも編集できる状態にはしていませんが、記事を書いてくださる人がいれば大歓迎です。下のコメント欄にまずはその旨を書いてください。 名前 コメント
https://w.atwiki.jp/motionboard/pages/49.html
はじめに チャート作成に必要なデータソースについての知識を集めました。 データソースを理解する MotionBoardをマスターするための一歩はデータソースから@またえこうじ@ぴたデジの人[note] 解説 まずデータソースとは何かを理解すること、データソースの構成、機能を把握すると、ボード作成の幅がグンと広がります。 そのデータソースの捉え方、テクニックについてご紹介しています。 データソースを使い回す データソースのコピー、名前変更、削除@WingArc1st[TECH BLOG] 解説 データソースに関する、基本的な編集方法です。 データソース(DS)を複数使う 売上と経費、利益を分かりやすく表現する@またえこうじ@ぴたデジの人[note] 解説 データソースを複数つなげて、売上と経費、利益をわかりやすく表現する方法です。 『専用データソース』と『作成済みデータセット』 『専用データソース』と『作成済みデータセット』でチャートを作成したときの違い@木戸しぃさぁ[note] 解説 チャートを作成する際、『専用データソース』と『作成済みデータセット』でどのような違いがあるのか紹介しています。
https://w.atwiki.jp/sapmania_bi70_delta/pages/26.html
クエリ実行時にソースシステムに直接アクセスするかをデータソースのオプションで設定可能となった ファイルとDBコネクトタイプのソースシステムに対しても可能となった 名前 コメント
https://w.atwiki.jp/nina_a/pages/61.html
テンプレート(Templates) このページを編集 概要 すべてのWPFコントロールは"見た目"を持たないように設計されている.ただし,既定の見た目を持っており,これからVisualTreeが作成される.この見た目を決めるものがコントロールテンプレートと呼ばれるものであり,XAMLで定義されている. コントロールの標準のテンプレートを表示する このプログラムは Matthew MacDonald:Pro WPF in C# 2010 Windows Presentation Foundation in .Net 4 に掲載されているものをもとに作成した. +コントロールの標準のテンプレートを表示するサンプルプログラム XAML Window x Class="WpfSampleApplication.MainWindow" xmlns="http //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns x="http //schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="600" Width="1000" Loaded="Window_Loaded" StackPanel Orientation="Horizontal" Name="layoutRoot" TreeView Name="lstTypes" SelectedItemChanged="lstTypes_SelectedItemChanged" Width="400"/ TextBox Name="txtTemplate" Width="600" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/ /StackPanel /Window C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Globalization; using System.Reflection; using System.Xml; using System.Windows.Markup; namespace WpfSampleApplication { /// summary /// MainWindow.xaml の相互作用ロジック /// /summary public partial class MainWindow Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { Type controlType = typeof(Control); List Type derivedTypes = new List Type (); // Search all the types in the assembly where the Control class is defined. Assembly assembly = Assembly.GetAssembly(typeof(Control)); foreach (Type type in assembly.GetTypes()) { // Only add a type of the list if it s a Control, a concrete class, // and public. if (type.IsSubclassOf(controlType) !type.IsAbstract type.IsPublic) { derivedTypes.Add(type); } } // Sort the types. The custom TypeComparer class orders types // alphabetically by type name. derivedTypes.Sort(new AlphabeticalComparer()); // Show the list of types. lstTypes.ItemsSource = derivedTypes; } private void lstTypes_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs object e) { try { // Get the selected type. Type type = (Type)lstTypes.SelectedItem; // Instantiate the type. ConstructorInfo info = type.GetConstructor(System.Type.EmptyTypes); Control control = (Control)info.Invoke(null); // Add it to the grid (but keep it hidden). control.Visibility = Visibility.Collapsed; layoutRoot.Children.Add(control); // Get the template. ControlTemplate template = control.Template; // Get the XAML for the template. XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; StringBuilder sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb, settings); XamlWriter.Save(template, writer); // Display the template. txtTemplate.Text = sb.ToString(); // Remove the control from the grid. layoutRoot.Children.Remove(control); } catch (Exception err) { txtTemplate.Text = " テンプレートの生成に失敗しました。 " + err.Message + " "; } } private class AlphabeticalComparer IComparer Type { public int Compare(Type x, Type y) { return string.Compare(x.FullName, y.FullName); } } } } カテゴリ:WPF 名前
https://w.atwiki.jp/playstationhome/pages/1114.html
▽メーカー一覧CapcomCodeglue B.V.Electronic ArtsElectronic Entertainment Expo 2011Electronic Entertainment Expo 2012FromSoftwareGranzellaHellfire GamesHudson SoftIREM SOFTWARE ENGINEERINGLIAR GAMELockwood PublishingLOOT™Mass Media GamesNAMCO BANDAI GamesnDreamsNIPPON ICHI SOFTWAREO-TwoPlayStation®HomeQ-GamesRed BullSCEJSONYSony Computer EntertainmentSPE-WPFSQUARE ENIXTECMO KOEI GAMESUbisoftWill日本コカ・コーラ照英王国-----▽ラウンジ一覧▼プライベートラウンジパーソナルスペース一覧クラブハウス一覧▼パブリックラウンジ常設ラウンジ(Homeラウンジ)一覧特設ラウンジ一覧▼グローバルラウンジグローバルラウンジ一覧 目次 SPE-WPF Inc.URL公式サイト Facebook Twitter ラウンジパーソナルスペース クラブハウス 常設ラウンジ 特設ラウンジグローバルラウンジ インタラクティブアイテムゲーム オブジェクト イベント 内容 SPE-WPF Inc. URL 公式サイト http // Facebook http // Twitter http // ラウンジ パーソナルスペース クラブハウス 常設ラウンジ 特設ラウンジ グローバルラウンジ インタラクティブアイテム ゲーム オブジェクト イベント コメント欄 ※掲載情報に関するコメントはこちらへどうぞ(スパム防止のため、URLの投稿は禁止しています)。 ※Wiki編集方法が分からない方は、こちらか情報提供板へ情報をお寄せください。文章体で書き込んで頂けると、Wikiへの反映もはやくなるかと思います。 ※攻略等の質問は質問掲示板へどうぞ。 名前 コメント すべてのコメントを見る
https://w.atwiki.jp/nina_a/pages/57.html
アニメーション このページを編集 概要 WPFでは,マージンなどの見た目に関わるプロパティの値を順次変化させることでアニメーションを実現する. XxxAnimationクラス WPFには時間の経過に応じて値を変化させるXxxAnimationクラスが用意されている.Xxxには変化させる値のタイプが入り,double型を変化させる場合にはDoubleAnimationクラスを利用する. +DoubleAnimationサンプル Window x Class="WpfSampleApplication.MainWindow" xmlns="http //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns x="http //schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" StackPanel Button Width="200" Height="100" アニメーションテスト Button.Triggers EventTrigger RoutedEvent="MouseEnter" BeginStoryboard Storyboard DoubleAnimation To="300" Duration="0 0 2" Storyboard.TargetProperty="(Button.Width)" / /Storyboard /BeginStoryboard /EventTrigger EventTrigger RoutedEvent="MouseLeave" BeginStoryboard Storyboard DoubleAnimation To="200" Duration="0 0 2" Storyboard.TargetProperty="(Button.Width)" / /Storyboard /BeginStoryboard /EventTrigger /Button.Triggers /Button /StackPanel /Window 主な依存プロパティ From アニメーションの開始値.指定しない場合は現在の値. To アニメーションの終了値.指定しない場合は既定の(オリジナルの)値. By アニメーションの変量.From+By=To.ToとByの両方が指定された場合はToが優先. Duration アニメーションの時間.Duration.Foreverで永遠に続く(無限大の時間の)アニメーション.Foreverを指定すると,無限大の時間をかけてFromからTo,Byまでアニメーションするため,変化しているように見えない.無限回続くアニメーションの意味ならばRepeatBehaviorにRepeatBehavior.Foreverをセットする. 主なプロパティ AccelerationRatio Dulationの内,加速に使う時間の割合.DecelerationRatioとの和が1を超えてはいけない. AutoReverse trueなら,アニメーション終了後,逆再生する FillBehavior アニメーション終了時の動作指定.既定は保留(アニメーション終了時の値を維持).Stopを指定すると終了(アニメーション終了時の値を破棄)する. DecelerationRatio Dulationの内,減速に使う時間の割合.AccelerationRatioとの和が1を超えてはいけない. RepeatBehavior アニメーションの繰り返し動作指定.既定は1回実行.回数や実行時間で指定. SpeedRatio アニメーションの速度.5を指定すれば5倍の早さ. ストーリーボード(Storyboard) アニメーションの対象(TargetNameとTargetProperty)をStoryboardで指定する.複数XxxAnimationを記述すれば,それらを同時実行できる. +Storyboardサンプル Storyboard DoubleAnimation To="300" Duration="0 0 2" AccelerationRatio="0.2" DecelerationRatio="0.2" Storyboard.TargetProperty="(Button.Width)" / DoubleAnimation To="300" Duration="0 0 2" AccelerationRatio="0.2" DecelerationRatio="0.2" Storyboard.TargetProperty="(Button.Height)" / /Storyboard この例ではTargetPropertyを各アニメーションごとに指定しており,TargetNameは指定していない. アニメーションを制御する 止めたり,リスタートしたり.それぞれのボタンのトリガーでPauseStoryBoardとかやってもBeginStoryBoardが見つからないので止まらない.なのでその親要素のStackPanelでまとめて記述.他の操作は MSDN 参照.再生速度とかもっと細かい制御はXAMLでは無理. +アニメーション制御サンプル Window x Class="WpfSampleApplication.MainWindow" xmlns="http //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns x="http //schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="400" Width="500" Grid Grid.RowDefinitions RowDefinition Height="*" / RowDefinition Height="Auto" / /Grid.RowDefinitions Button Width="200" Height="100" Name="dest" Grid.Row="0" アニメーションテスト /Button StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center" Button Width="100" Margin="5" Content="開始" Name="start" / Button Width="100" Margin="5" Content="停止" Name="pause" / Button Width="100" Margin="5" Content="再開" Name="resume" / Button Width="100" Margin="5" Content="終了" Name="stop" / StackPanel.Triggers EventTrigger RoutedEvent="Button.Click" SourceName="start" BeginStoryboard x Name="animation" Storyboard Storyboard.TargetName="dest" DoubleAnimation To="300" Storyboard.TargetProperty="(Button.Width)" FillBehavior="Stop" Duration="0 0 15"/ DoubleAnimation To="300" Storyboard.TargetProperty="(Button.Height)" FillBehavior="Stop" Duration="0 0 15"/ /Storyboard /BeginStoryboard /EventTrigger EventTrigger RoutedEvent="Button.Click" SourceName="pause" PauseStoryboard BeginStoryboardName="animation"/ /EventTrigger EventTrigger RoutedEvent="Button.Click" SourceName="resume" ResumeStoryboard BeginStoryboardName="animation"/ /EventTrigger EventTrigger RoutedEvent="Button.Click" SourceName="stop" StopStoryboard BeginStoryboardName="animation"/ /EventTrigger /StackPanel.Triggers /StackPanel /Grid /Window イージング(Easing) イージングを使うと値の変化の仕方を変えることができる.全てのEasingFunctionについては MSDN 参照. +イージング関数にPowerEaseを指定するサンプル DoubleAnimation To="300" Storyboard.TargetProperty="(Button.Width)" Duration="0 0 2" DoubleAnimation.EasingFunction PowerEase EasingMode="EaseInOut" Power="2" / /DoubleAnimation.EasingFunction /DoubleAnimation すべてのEasingFunctionはEasingModeというプロパティを持っている. EaseIn アニメーション開始付近でイージングする EaseOut アニメーション終了付近でイージングする EaseInOut アニメーション開始と終了付近の両方でイージングする キーフレーム指定によるアニメーション XxxAnimationの変わりにXxxAnimationUsingKeyFrameを使うと,指定の時刻(キーフレーム)における値を指定することでアニメーションを実現できる. +キーフレーム指定によるアニメーション DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Button.Width)" LinearDoubleKeyFrame Value="300" KeyTime="0 0 1"/ DiscreteDoubleKeyFrame Value="200" KeyTime="0 0 2" / SplineDoubleKeyFrame Value="100" KeyTime="0 0 3" / EasingDoubleKeyFrame Value="300" KeyTime="0 0 4" EasingDoubleKeyFrame.EasingFunction BounceEase / /EasingDoubleKeyFrame.EasingFunction /EasingDoubleKeyFrame /DoubleAnimationUsingKeyFrames キーフレームを指定するときにはYyyXxxKeyFrameを使う.Yyyにはそのキーフレームまでの値の変化の仕方が入り,Linear(直線),Discrete(不連続),Spline(スプライン),Easing(指定のイージング関数)の4種類. このサンプルでは,1秒経過まで直線的に300まで変化し,2秒経過した瞬間に200に変化,3秒経過までスプライン曲線を描いて100まで変化,その後EasingFunctionに指定されたBounceEaseを使って300まで変化する. カテゴリ:WPF 名前
https://w.atwiki.jp/atachi/pages/38.html
基本的な使い方 [#c237efa6] 入力モードでアイテム選択 [#y4d2d9ff] アイテム表示方法 [#y2b14180] 参考サイト 基本的な使い方 プロパティを全く指定しない場合は、コントロールをクリックするとアイテムを選択するためのドロップダウンボックスが表示される。 ComboBoxItemを記述する ComboBox ComboBoxItem Content="北海道" / ComboBoxItem Content="青森" / ComboBoxItem Content="秋田" / ComboBoxItem Content="岩手" / /ComboBox ItemsSourceで要素を指定する Window xmlns sys="clr-namespace System;assembly=mscorlib" xmlns col="clr-namespace System.Collections;assembly=mscorlib" Window.Resources col ArrayList x Key="items" sys String 北海道 /sys String sys String 青森 /sys String sys String 秋田 /sys String sys String 岩手 /sys String sys String 福島 /sys String /col ArrayList /Window.Resources Grid ComboBox ItemsSource="{StaticResource items}" / /Grid /Window 入力モードでアイテム選択 IsEditable を True にすると、入力によってアイテムを選択させることができる。 ただし、選択項目にない文字列などを入力すると、コンボボックスは何も選択されていないことになり、ComboBox.SelectedItemはNullとなる。 ComboBox IsEditable="True" ComboBoxItem Content="北海道" / ComboBoxItem Content="青森" / ComboBoxItem Content="秋田" / ComboBoxItem Content="岩手" / /ComboBox アイテム表示方法 ComboBoxItemではアイテムのフォントや背景色を設定できる。 ComboBox ComboBoxItem HorizontalAlignment="Right" Content="北海道" / ComboBoxItem Foreground="Blue" Content="青森" / ComboBoxItem FontSize="7" FontWeight="Bold" FontFamily="MS 明朝" Content="秋田" / ComboBoxItem Background="Red" Content="岩手" / /ComboBox 参考サイト WPFのComboBox http //www.codeproject.com/KB/WPF/MultiComboBox.aspx